﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects.Data.What;
using Rhino.Mocks;
using Xunit;

namespace DBMigrator.Core.Tests.DbObjects.Data
{
    public class BaseWhatTests
    {
        private readonly IAdditionalWhat additionalWhat;
        private readonly IWhatColumnList columnList;

        public BaseWhatTests()
        {
            additionalWhat = MockRepository.GenerateMock<IAdditionalWhat>();
            columnList = MockRepository.GenerateMock<IWhatColumnList>();
        }

        [Fact]
        public void ConstructorShouldThrowIfAdditionalWhatIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => new BaseWhatImplentation(null, columnList));
        }

        [Fact]
        public void ConstructorShouldSetAdditionalWhat()
        {
            Assert.Equal(additionalWhat, new BaseWhatImplentation(additionalWhat, columnList).AdditionalWhat);
        }

        [Fact]
        public void ConstructorShouldThrowIfColumnListIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => new BaseWhatImplentation(additionalWhat, null));
        }

        [Fact]
        public void ConstructorShouldSetColumnList()
        {
            Assert.Equal(columnList, new BaseWhatImplentation(additionalWhat, columnList).ColumnList);
        }

        private class BaseWhatImplentation : BaseWhat
        {
            public BaseWhatImplentation(IAdditionalWhat additionalWhat, IWhatColumnList columnList)
                : base(additionalWhat, columnList)
            {
            }
        }
    }
}
